import os
import shutil

from tqdm import tqdm

imagePath="G:\数据集\植保所\分类目标图片\斑潜蝇危害状\原始数据"
savePath="G:\数据集\植保所\分类目标图片\斑潜蝇危害状\整理出的全部图片"

for dirpath, dirnames, filenames in tqdm(os.walk(imagePath)):
    for filename in filenames:
        if filename.endswith(".png") or filename.endswith(".jpg") or filename.endswith(".JPG") or filename.endswith(".bmp"):
            shutil.copy(os.path.join(dirpath,filename),os.path.join(savePath,filename))